﻿using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace BruteForce.Animation
{
    public delegate void TransitionValueChanged(EaseInOutTransition transition);

    public class EaseInOutTransition : Transition
    {
        public EaseInOutTransition(double duration)
            : base(duration)
        {
        }


        public TransitionValueChanged Callback { get; set; }

        public override void Interpolate(GameTime time)
        {
            var b = 0;
            var c = 1;
            var t = Time;
            var d = Duration;

            var ts = (t /= d) * t;
            var tc = ts * t;
            Value = b + c * (-2 * tc + 3 * ts);

            if (Callback != null) Callback(this);
        }
    }
}